{extend name='base' /}
{block name='content' /}
<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">记录</li>
                <li class=""><a href="{:url('admin/dp/record_add')}">添加</a></li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="">
                        <table class="layui-table" lay-size="sm">
                            <thead>
                            <tr>
                                <th style="width: 30px;">ID</th>
                                <th>名称</th>
                                <th>描述</th>
                                <th>类型</th>
                                <th>图片</th>
                                <th style="width: 130px;">创建时间</th>
                                <th style="width: 120px;">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach name="record_list" item="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.name}</td>
                                <td>{$vo.desc}</td>
                                <td>{$vo.type_name}</td>
                                <td>
                                    <img src="/public/{$vo.img}" alt="" width="100" height="100">
                                </td>
                                <td>{$vo.create_time}</td>
                                <td style="width:200px;display:felx">
                                    <div class="layui-btn-group">
                                        <a href="{:url('admin/dp/record_edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-sm" title="编辑"><i class="layui-icon">&#xe642;</i></a>
                                        <a href="{:url('admin/dp/record_delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-sm ajax-delete" title="删除"><i class="layui-icon">&#xe640;</i></a>
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </form>
                    <!--分页-->
                    {$record->render()}
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['layer', 'form', 'upload'], function() {
        var $ = layui.jquery, layer = layui.layer, upload = layui.upload;
        var form = layui.form;

        // // 数据导入
        // var uploadInst = upload.render({
        //     elem: "#import",
        //     url: "{:url('admin/tbb/import')}",
        //     accept: 'file',
        //     before: function(obj) {
        //         layer.load();
        //     },
        //     done: function(res, index, upload) {
        //         layer.closeAll('loading');
        //         layer.msg('导入成功');
        //         setTimeout(function() {
        //             window.location.reload();
        //         }, 1500);
        //     },
        //     error: function(index, upload) {
        //         layer.closeAll('loading');
        //     }
        // });

        // 通用删除
        $('.ajax-delete').on('click', function() {
            var _href = $(this).attr('href');
            layer.open({
                shade: false,
                content: '确定删除？',
                btn: ['确定', '取消'],
                yes: function(index) {
                    $.ajax({
                        url: _href,
                        type: "get",
                        success: function(info) {
                            if (info.code === 1) {
                                setTimeout(function() {
                                    window.location.reload()
                                }, 1000);
                            }
                            layer.msg(info.msg);
                        }
                    });
                    layer.close(index);
                }
            });

            return false;
        });
    });

</script>
{/block}
